﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;

namespace Wicresoft.EKA.BOSync
{
    public abstract class AbstractService<T>:IService<T>,IService
    {
        public void ImportData(string data, IDB db)
        {
            T t = JsonConvert.DeserializeObject<T>(data);

            IList<T> list = new List<T>();
            list.Add(t);

            ImportData(list, db);
        }

        public virtual void ImportData(IList<T> list, IDB db)
        {
            db.BulkInsert<T>(list);
            SyncData();
        }

        public abstract void SyncData();
    }
}
